<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>巴士下架</title>
<meta name="decorator" content="default" />
<script type="text/javascript">
		$(document).ready(function() {
			$("#licno").focus();
			var updateflag = $("#updateorview").val();
			
			//查看时应将所有控件禁用
			if (updateflag == "V"){
				$(":input").prop("disabled", true);
				$(":button").prop("disabled", true);
				$(":submit").prop("disabled", true);
				$("select").prop("disabled", true);
				$("#btnCancel").prop("disabled", false);
			}
			$("#inputForm").validate({
			    rules: {
			    	offbegin: {datecmp:true},
			    	offend:{datecmp:true},	    	
			    },
			    messages: {},
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		$.validator.addMethod("datecmp", function(value, element) {
			var bigdate = $('#offend').val();
			var smadate = $('#offbegin').val();
			if (bigdate != null && bigdate != "" && smadate != null && smadate != ""){
				var big=new Date(bigdate.replace("-", "/").replace("-", "/"));
				var small = new Date(smadate.replace("-", "/").replace("-", "/"));
				if(big<small){
					return false;
				} else {
					return true;
				}
			}else
			{
				return true;
			}			
		}, "结束日期必须大于开始日期！");
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/bus/tCompBus?types=${types}">巴士管理列表</a></li>
		<li class="active"><a
			href="${ctx}/bus/tCompBus/offSellBus?id=${tCompBus.id}&types=${types}">巴士下架</a></li>
	</ul>
	<br />
	<form:form id="inputForm" modelAttribute="tCompBus"
		action="${ctx}/bus/tCompBus/offSellBus" method="post"
		class="form-horizontal">
		<input type="hidden" id="types" name="types" value="${types}">
		<input type="hidden" id="updateorview" name="updateorview" value="${updateorview}" />
		<form:hidden path="id" />
		<sys:message content="${message}" />
		<div class="control-group">
			<label class="control-label">归属公司:</label>
			<div class="controls">
				<c:if test="${types==1}">
					<input type="hidden" id="office.id" name="office.id"  value="${tCompBus.office.id}">
	  				<input type="text" id="office.name" name="office.name" class="span4"
						value="${tCompBus.office.name}"   readonly="readonly">	
				</c:if>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">车牌号：</label>
			<div class="controls">
				<input name="licenseno" id="licenseno" type="text" value="${tCompBus.licenseno}" readonly="readonly" class="span4">
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">下架开始日期：</label>
			<div class="controls">
				<input name="offbegin" id="offbegin" type="text" readonly="readonly" 
					class="span4 Wdate required"
					value="<fmt:formatDate value="${tCompBus.offbegin}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false,minDate:'${tomorrow}'});" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">下架结束日期：</label>
			<div class="controls">
				<input name="offend" id="offend" type="text" readonly="readonly"
					 class="span4 Wdate required"
					value="<fmt:formatDate value="${tCompBus.offend}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false,minDate:'${tomorrow}'});" />
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="bus:tCompBus:edit">
				<input id="btnSubmit" class="btn btn-primary" type="submit"
					value="确定下架" />&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回"
				onclick="history.go(-1)" />
		</div>
	</form:form>
</body>
</html>